<?php
/*
 * record 控制器
 */
require_once APP_ROOT.'/include/action/commonAction.php';
class Record_Action extends commonAction{

	function index(){
		$page_title ="我的录入";
		extract($this -> options_cache);
		$site_title = $page_title . ' - ' . $site_name;
		include View::getView('record_index');
	}

	function edit(){
		$page_title ="编辑录入";
		extract($this -> options_cache);
		$site_title = $page_title . ' - ' . $site_name;

		$shop_id = isset($_GET['s'])?intval($_GET['s']):0;
		$ditch_id = isset($_GET['d'])?intval($_GET['d']):0;

		$Shop_Model = new Shop_Model();
		if(!$shop_id || !$ditch_id){
			// 选择店铺和渠道
			$shopes = $Shop_Model -> getDatas(" ORDER BY sid ASC ");
			include View::getView('record_edit');
		}else{

			$shop = $Shop_Model -> getOneData($shop_id);

			$Ditches_Model = new Ditches_Model();
			$ditch = $Ditches_Model -> getOneData($ditch_id);
			$tplname = 'record_edit_'.$ditch['alias'];
			include View::getView($tplname);
		}
		
	}

	function handle(){
		$token = isset($_REQUEST['token']) ? addslashes($_REQUEST['token']) : '';
        if ($token != LoginAuth::genToken()) {
            exit('{"code":108,"msg":"权限不足！"}');
        }

		$action = isset($_POST['action'])?trim($_POST['action']):'';
		$methodName = 'handle_'.$action;
		if(method_exists($this, $methodName)){
			$this -> $methodName();
		}
	}

	private function handle_edit(){
		$sid = isset($_POST['sid'])?intval($_POST['sid']):0;
		$did = isset($_POST['did'])?intval($_POST['did']):0;
		if(!$sid||!$did){
			exit('{"result":911,"msg":"错误的店铺或者渠道！"}');
		}
		
	}

}